﻿using System;
using System.Web.Mvc;
using CID.Domain;

namespace CID.Web.Models
{
    public abstract class BaseViewModel<T> : IViewModel
        where T : IEntity
    {
        [HiddenInput(DisplayValue = false)]
        public int Id { get; set; }

        public BaseViewModel()
        { 
        }

        public BaseViewModel(T model)
        {
            Id = model.Id;
        }

        public virtual void UpdateModel(T model)
        {
            if (Id != model.Id) throw new Exception("The IDs don't match");
        }
    }
}